package day01;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressDemo01 {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress localAddress = InetAddress.getLocalHost();
        System.out.println("HostName:="+localAddress.getHostName());
        System.out.println("IP="+localAddress.getHostAddress());
        InetAddress[] inetAddresses = InetAddress.getAllByName("www.baidu.com");
        for (InetAddress inet : inetAddresses) {
            System.out.println("新浪:ip="+inet.getHostAddress()+"主机名="+inet.getHostName());
        }
    }
}
